package com.syf.controller.RJController;

import cn.hutool.db.sql.Order;
import com.syf.model.Mails;
import com.syf.rocker.Source;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author syf
 * @create 2022-01-29 15:14
 */
@RestController
public class testController {

    @Autowired
    private Source source;


    @PostMapping("/mail/send")
    public void send(){

        Mails mails = new Mails("1548120092@qq.com","好标题","好多消息啊！！！");
        MessageBuilder<Mails> mailMessageBuilder = MessageBuilder
                .withPayload(mails)
                .setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON);
        boolean send = source.mailOut().send(mailMessageBuilder.build());

        System.out.println("MQ 产生消息:"+send);
    }


}
